package webmanage

import (
	"context"
	"github.com/go-kratos/kratos/v2/log"
	"gorm.io/gorm"
	"phm/models/generator/model"
)

type SysPermissionRepo interface {
	CreateSysPermission(ctx context.Context, uModel *model.SysPermission, db *gorm.DB) error
	UpdateSysPermission(ctx context.Context, uModel *model.SysPermission, db *gorm.DB) error
	DeleteSysPermissionByIds(ctx context.Context, ids []string, db *gorm.DB) error
	GetSysPermissionById(ctx context.Context, id string) (*model.SysPermission, error)
	GetSysPermissionByIds(ctx context.Context, ids []string) ([]*model.SysPermission, error)
	// GetDB 得到db以方便事务处理
	GetDB() *gorm.DB
	GetSysPermissionByRoleId(ctx context.Context, roleId string) ([]*model.SysPermission, error)
}

type SysPermissionUseCase struct {
	permissionRepo SysPermissionRepo
	log            *log.Helper
}

func NewSysPermissionUseCase(repo SysPermissionRepo, logger log.Logger) *SysPermissionUseCase {
	return &SysPermissionUseCase{
		permissionRepo: repo,
		log:            log.NewHelper(logger),
	}
}
